﻿@model List<House.DTO.RoleDTO>
@{
    ViewBag.Title = "Create";
}
<div class="pd-20">
    <form class="form form-horizontal" id="form-role-add">
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" value="" placeholder="" id="PhoneNum" name="PhoneNum" nullmsg="手机不能为空">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>管理员：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" value="" placeholder="" id="Name" name="Name" datatype="*2-16" nullmsg="用户名不能为空">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>初始密码：</label>
            <div class="formControls col-5">
                <input type="password" placeholder="密码" autocomplete="off" value="" class="input-text" datatype="*6-20" nullmsg="密码不能为空" name="Password" id="Password">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-5">
                <input type="password" placeholder="确认新密码" autocomplete="off" class="input-text Validform_error" errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="Password" id="PasswordConfirm" name="PasswordConfirm">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>邮箱：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" placeholder="" name="Email" id="Email" datatype="e" nullmsg="请输入邮箱！">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3">城市：</label>
            <div class="formControls col-5">
                @Html.DropDownList("CityId", (List<SelectListItem>)ViewBag.cityList, new { @class = "select-box" })
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2">角色选择：</label>
            <div class="formControls col-10">
                <dl class="permission-list">
                    <dt>
                        <label></label>
                    </dt>
                    <dd>
                        <dl class="cl permission-list2">
                            @foreach (var item in Model)
                            {
                                <dt>
                                    <label class="">
                                        <input type="checkbox" value="@item.Id" name="RoleIds" id="permission_@item.Id">
                                        @item.Name
                                    </label>
                                </dt>
                            }
                        </dl>
                    </dd>
                </dl>
            </div>
        </div>
        <div class="row cl">
            <div class="col-10 col-offset-2">
                <button type="button" class="btn btn-success radius" id="btn_Add" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
    </form>
</div>
@section footScript{
    <script>
        $(function () {
            var validform = $("#form-role-add").Validform();

            $("#btn_Add").click(function () {
                var formdata = $("#form-role-add").serializeArray();
                if (validform.check(false)) {
                    $.post("/AdminUser/Create", formdata, function (data) {
                        if (data.State == 1) {
                            layer.msg(data.ErrorMessage, { icon: 6 });
                            parent.location.reload();
                        } else {
                            layer.msg(data.ErrorMessage, { icon: 6 });
                        }
                    }, "json")
                }
            })
        })
    </script>
}
